window.onload = function () { 
    let canvas = $('.canvas')
    let container = $('.container')
    let ctx = canvas.getContext('2d')
    getText()
    ctx.fillStyle = '#c0c0c0'
    ctx.fillRect(0, 0, 300, 150)
    canvas.addEventListener('mousedown', () => { 
        canvas.onmousemove = (e) => { 
            move(e)
        }
    })
    canvas.addEventListener('mouseup', () => { 
        canvas.onmousemove = null
    })
    function getText() { 
        let text = ['一个亿', '别墅', '豪车', '5元红包', '谢谢惠顾']
        let index = Math.floor(Math.random() * 5)
        container.innerHTML = text[index]
    }
    function move(e) { 
        ctx.clearRect(e.clientX,e.clientY,12,12)
    }
}
